﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Model;
using YiSha.Entity;
using YiSha.Model;
using YiSha.Admin.Web.Controllers;
using YiSha.Entity.YiDongYuan;
using YiSha.Business.YiDongYuan;
using YiSha.Model.Param.YiDongYuan;
using YiSha.Web.Code;
using System.Drawing;
using System.IO;
using Microsoft.AspNetCore.Http;
using System.Text;

namespace YiSha.Admin.Web.Areas.YiDongYuan.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-06-07 10:00
    /// 描 述：非道路移动机械控制器类
    /// </summary>
    [Area("YiDongYuan")]
    public class AdminDeskController : BaseController
    {


        private MechanicsApplyBLL mechanicsApplyBLL = new MechanicsApplyBLL();
        private DetectionTaskBLL taskBLL = new DetectionTaskBLL();
        #region 视图功能

        [AuthorizeFilter("yidongyuan:mechanics:view")]
        public ActionResult AdminLTEDesktop()
        {
            //待审核
            MechanicsApplyListParam mechanicsApplyParam = new MechanicsApplyListParam();
            mechanicsApplyParam.auditStatus = 0;
            long dshCount = mechanicsApplyBLL.GetList(mechanicsApplyParam).Result.Data.Count;
            //已审核
            mechanicsApplyParam.auditStatus = 1;
            long yshCount = mechanicsApplyBLL.GetList(mechanicsApplyParam).Result.Data.Count;
            ViewBag.dshCount = dshCount;
            ViewBag.yshCount = yshCount;
            //待核实 DetectionType=0 And DetectionStatus = 0;
            DetectionTaskListParam taskParam = new DetectionTaskListParam();
            taskParam.DetectionType = 1;
            //复检 DetectionType=1
            long fjCount = taskBLL.GetRecheclCount(taskParam.DetectionType).Result;
            ViewBag.fjCount = fjCount;//fjCount
            taskParam.DetectionType = 0;
            taskParam.DetectionStatus = 0;
            long dhsCount = taskBLL.GetList(taskParam).Result.Data.Count;
            //已检测 DetectionType=0 And DetectionStatus = 1;
            taskParam.DetectionStatus = 1;
            long yjcCount = taskBLL.GetList(taskParam).Result.Data.Count;
            ViewBag.dhsCount = dhsCount;
            ViewBag.yjcCount = yjcCount;

            return View();
        }
        #endregion

        [HttpPost]
        [AuthorizeFilter("yidongyuan:spareplate:add,yidongyuan:spareplate:edit")]
        public async Task<ActionResult> MechanicsRegionReport(string type)
        {
            
            TData<List<RegionReportEntity>> obj = await mechanicsApplyBLL.GetRegionList(type);
            return Json(obj);
        }
        
        [HttpPost]
        [AuthorizeFilter("yidongyuan:spareplate:add,yidongyuan:spareplate:edit")]
        public async Task<ActionResult> TaskRegionReport(string type)
        {
            
            TData<List<RegionReportEntity>> obj = await taskBLL.GetRegionList(type);
            return Json(obj);
        }


    }
}
